package com.example.mybatis.controller;

import com.example.mybatis.entity.UserInfo;
import com.example.mybatis.service.IUserInfoService;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.FileNotFoundException;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    private final IUserInfoService userInfoService;

    public UserController(IUserInfoService userInfoService) {
        this.userInfoService = userInfoService;
    }

    @GetMapping("/list")
    public List<UserInfo> list() {
        return userInfoService.userList();
    }

    @GetMapping("/list2")
    public List<UserInfo> list2() {
        return userInfoService.getUserList();
    }

    public static void main(String[] args) throws FileNotFoundException {
        String classpath = ResourceUtils.getURL("classpath:").getPath();
        System.out.println("classpath:" + classpath);
    }
}
